{// 引入标签库 }
<tagLib name="html" />
{// 加载头部公共文件 }
<include file="Public:top" />

<style type="text/css">
.td1{text-align: center; line-height: 25px;}
#w1 tr{height: 40px; padding: 5px;}
.operate1 a{ padding: 0 5px;}
.operate1 span{display: none;}
.datalisttr td{height: 30px; line-height: 30px;}
#outExcelTable td{height:30px; line-height: 30px;}
#outExcelTable{margin:10px;}
.td2 input{border: 1px solid #cccccc;}
.td3 input{border-bottom:1px #DDD solid;}
</style>
	<div class="Bdy">

		<div class="aside" id="aside">
			<ul class="nav">
				<li>
					<a data-ca="aside-files" data-pv="" href="__URL__/index/week/{$preweek}" class="up_document"> <b>上一周</b>
					</a>
				</li>
				<li>
					<a data-ca="aside-outlink" data-pv="" href="__URL__/index/week/{$curweek}" class="all-file selected"> <b>当周安排</b>
					</a>
				</li>
				<li>
					<a data-ca="aside-recycle" data-pv="" href="__URL__/index/week/{$nextweek}" class="down_document">
						<b>下一周</b>
					</a>
				</li>
			</ul>
			<ul class="nav">
				<!-- <li>
					<a data-ca="aside-apps" href="#" class="apps">
						<b>应用管理</b>
					</a>
				</li> -->
			</ul>
			<div id="user-space" class="user-space">
				<!-- <div id="spacePie">
					<p style="top:-200%"></p>
				</div> -->
			</div>
		</div>

		<div id="mainer" class="noSelect loading2">
			<div class="mainT"></div>
			<div style="display: block;" id="filemangebox" class="main dn">

				<div class="maint">
					<div class="mainH operatebar" id="file-operatebar">
						<ul class="operate operate-group">
							<li class="operate">
								<button data-ca="operatebar-back" class="btn back btn_disable btnDis" id="back" title="返回">
									<i class="i"></i>
								</button>
							</li>
							<!-- <li class="operate">
								<button data-ca="operatebar-upload" class="btn upload" id="upload" title="上传新的文件">
									<i class="i i4"></i>
								</button>
							</li> -->
							<li class="operate">
								<button id="addNewPlan" data-ca="operatebar-newfolder" class="btn newfolder" title="添加周计划">
									<i class="i i5"></i>
								</button>
							</li>
							<li class="operate">
								<button id="outExcel" data-ca="operatebar-outExcel" class="btn outExcel" title="导出电子表格">
									<i class="i i55"></i>
								</button>
							</li>
							<li id="showtitle1">周工作去向表</li>
						</ul>

						<div class="switch-view">
							<a data-ca="switchView-list" href="javascript:void(0)" class="list list-selected" title="切换到列表模式"></a>
							<a data-ca="switchView-icon" href="javascript:void(0)" class="icon" title="切换到缩略图模式"></a>
						</div>

						<div class="sort">
							<h2 class="desc">
								排序： <em><b>时间</b>
									<i class="i i2"></i></em> 
							</h2>
							<div class="dropDown2 dn">
								<ul class="dropMenu">
									<li>
										<a href="javascript:void(0)" class="date desc">
											时间
											<i class="i i2"></i>
										</a>
									</li>
									<li>
										<a href="javascript:void(0)" class="size desc">
											大小
											<i class="i i2"></i>
										</a>
									</li>
									<li>
										<a href="javascript:void(0)" class="name desc">
											名称
											<i class="i i2"></i>
										</a>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="list-view" id="file-list">
						<table class="tbl" id="tb1">
							<thead>
								<tr>
									<th width="60px">日期</th>
									<th width="5%">时间</th>
									<th width="35%">内容</th>
									<th width="15%">地点</th>
									<th width="20%">参加人员</th>
									<th width="110px">操作</th>
									<!-- <th width="10%">操作</th> -->
								</tr>
							</thead>
							<tbody class="list-data-container" id="tbody1">
								<eq name="waFlag" value="0">
								  <volist name="list" id="vo">
								    <tr id="" data-file-id="" class="">
										<td rowspan="2" class="td1">{$vo.showWeek}<br>({$vo.showDate|toDate='Y-m-d'})</td>
										<td class="quickadd" data-d='{$vo.showDate|toDate='Y-m-d'}'>上午</td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
									</tr>
									<tr data-file-id="" class="">
									  <td class="quickadd" data-d='{$vo.showDate|toDate='Y-m-d'}'>下午</td>
									  <td>&nbsp;</td>
									  <td>&nbsp;</td>
									  <td>&nbsp;</td>
									  <td>&nbsp;</td>
								  	</tr>
								  </volist>
								<else />
								  <volist name="list" id="vo">
								  	<tr id="tr{$vo.id}" class="datalisttr" data-id={$vo.id}>
									  <td class="td1" >{$vo.week}<br>{$vo.riqi|toDate='Y-m-d'}</td>
									  <td class="quickadd" data-d='{$vo.riqi|toDate='Y-m-d'}'>{$vo.sxw}</td>
									  <td class="tdOver u{$vo.userid}">{$vo.title}</td>
									  <td class="tdOver u{$vo.userid}">{$vo.address}</td>
									  <td class="tdOver u{$vo.userid}">{$vo.Participants}</td>
									  <td class="operate1 tdOver {$vo.emptyf} u{$vo.userid}"><span><a href="#" onclick="showDetails({$vo.id})">详情</a><a href="#" onclick="delSelf({$vo.id})">删除</a><a href="#" onclick="edit({$vo.id})">编辑</a></span>
									  <!-- {$vo.remarks} --></td>
								  	</tr>
								  </volist>
								</eq>
							</tbody>
						</table>

						<ul style="display: none;" class="dropMenu dropMenuAbs contextmenu"></ul>
					</div>
				</div>

			</div>
<include file="Public:foot" />

<!-- /*用于显示隐藏的内容，弹出窗口等*/ -->
<div class="hide">
	<div id="w1" class="easyui-window" title="添加周工作去向" iconCls="icon-save" style="width:600px;height:470px;padding:5px;" closed="true" collapsible="false" minimizable="false" maximizable="false" resizable="false">
		<div class="easyui-layout" fit="true">
			<div region="center" border="false" style="padding:10px;background:#fff;border:1px solid #ccc;" id='list4'>
			  <form method='post' id="ff" action="__URL__/insert/" >
			    <input name="id" type="hidden" id="id" value="0"/>
				<table>
					<tr>
						<td>日期：</td><td><input class="easyui-datebox" name="riqi" id="riqi" required="true"/><input name="week" type="hidden" id="week"/>&nbsp;&nbsp;上午<input type="radio" name="sxw" value="上午" checked>&nbsp;&nbsp;下午<input type="radio" name="sxw" value="下午"></td>
					</tr>
					<tr>
						<td>内容：</td><td><input class="input3" name="title" id="title" value="听课/调研" required="true"></input></td>
					</tr>
					<tr>
						<td>地点：</td><td><input class="input3" name="address" id="address" required="true"></input></td>
					</tr>
					<tr>
						<td>人员：</td><td><input class="input3" name="Participants" id="Participants" value="{$Think.session.loginUserName}"></input></td>
					</tr>
					<tr>
						<td>备注：</td><td><html:editor id="editor" name="remarks" type="KEMINI" style="height:200px;width:450px;"></html:editor></td>
					</tr>
				</table>
			  </form>
			</div>
			<div region="south" border="false" style="text-align:right;padding:5px 0; height:35px">
				<a class="easyui-linkbutton" iconCls="icon-filesave" onclick="submitForm(0)">保存</a>
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="submitForm(1)">保存并增加下一条</a>
				<a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0)" onclick="close_window()">关闭</a>
			</div>
		</div>
	</div>
	
	<div id="showExcelDiv">
		<form method="post" id="form2" name="form2">
			<table class="" style="width:570px" align="center" id="outExcelTable">

				<tr>
					<Td class="tLeft" colspan="4">
						表格标题：
						<input type="text" class="huge bLeft input3" value="香洲区教科培中心周工作去向表" id="e_title" />	
					</Td>
				</tr>
				<tr>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="riqi" checked="checked" /> 	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="日期" id="t_riqi" /> &nbsp
					</td>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="week" checked="checked" />	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="星期" id="t_week" />	&nbsp
					</td>
				</tr>
				<tr>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="sxw" checked="checked" />	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="时间" id="t_sxw" />	&nbsp
					</td>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="title" checked="checked" />	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="内容" id="t_title" />&nbsp	
					</td>
				</tr>
				<tr>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="address" checked="checked" />	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="去向地点" id="t_address" />&nbsp	
					</td>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="Participants" checked="checked" />	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="人员" id="t_Participants" />&nbsp
					</td>
				</tr>
				<tr>
					<td class="tRight td2">
						&nbsp<input type="checkbox" value="remarks" checked="checked" />	
					</td>
					<td class="tLeft td3">
						<input type="text" class="medium bLeft input4" value="备注" id="t_remarks" />&nbsp	
					</td>
					<td ></td>
					<td ></td>
				</tr>
				<tr>
					<Td class="tLeft" colspan="4">
						Exlce版本：
						<input name="eType" type="radio" value="Excel5" checked="checked" />	
						2003版本
						<input name="eType" type="radio" value="Excel2007" />	
						2007版本
					</Td>
				</tr>
			</table>
		</form>
		<!--导出excel的模块名，这个要写在form2之外-->	
		<input name="modelName" id="modelName" type="hidden" value="Weekwa" />	
	</div>
</div>

<script type="text/javascript">
$(function(){
	//表格隔行换色，鼠标经过颜色
	$("#tb1 tr").mouseover(function() {
        $(this).addClass("over");
        $('.over span').show();
        $('.emptyf span').hide();//隐藏空单元格的操作按钮
    }).mouseout(function() {
    	$('.over span').hide();
        $(this).removeClass("over");
    });
    //传入的参数是对应的列数从0开始，哪一列有相同的内容就输入对应的列数值
	$("#tbody1").rowspan(0);
	$("#tbody1").rowspan(1);
	
	//添加周计划按钮点击时弹出窗口,清空表单，与更新操作区分。
	var flag_quick=-1;
	$('#addNewPlan').click(function(event) {
		$('#id').val(0);
		$('#ff')[0].reset();
		$('#editor').val('');
		editor.html('');
		$('#riqi').datebox("setValue",GetDateStr(0));//今天日期并填充
		$('#w1').window('open');
		//添加标志与快速添加区分
		flag_quick=0;
	});	
	//双击单元格行时进行编辑操作
	$('.datalisttr').dblclick(function(){
		//edit($(this).data('id'));
	})

	$("#address").click(function(){
		var A_top 	= $(this).offset().top + $(this).outerHeight(true);  //  1
		var A_left 	= $(this).offset().left;
		$('#schoolList').bgiframe();
		$('#schoolList').show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px","z-index":9999});
	});
	//快速添加
	var curT1;//记录被点击的单元格，日期
	$(".quickadd").click(function(){
		flag_quick 	= 1;
		curT1 		= $(this);
		var A_top 	= $(this).offset().top+26;// + $(this).outerHeight(true);  //  1
		var A_left 	= $(this).offset().left;
		$('#schoolList').bgiframe();
		$('#schoolList').show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px","z-index":9999});
	});
	$('#schoolList li').click(function(event) {
		$('#address').val($(this).html());
		$('#schoolList').hide();
		if(flag_quick){
			$('#riqi').datebox('setValue',curT1.data('d'));
			$("input[name=sxw][value="+curT1.html()+"]").attr("checked",'checked');
			submitForm(0);
		}
	});
	
});

function submitForm(nextflag){
	$('#backUrl').val(SELF);
	editor.sync();
	$('#week').val($('#riqi').datebox('getValue'));
	var id = $('#id').val();
	if(id==0){
		url = "__URL__/insert/";
	}else{
		url = "__URL__/update/";
	}
	$('#ff').ajaxSubmit({
     	type: "post",
     	url: url,
     	dataType: "json",
     	success: function(result){
     		if(result.status==1){
     			//$.messager.show({title:'提示信息',msg:result.info,timeout:2000,showType:'slide'});
     			if(nextflag){
     				$.messager.show({title:'提示信息',msg:result.info,timeout:2000,showType:'slide'});
     				$('#id').val(0);
     				$('#riqi').datebox('setValue','');
     				$('#title').val('听课/调研');
     				$('#address').val('');
     			}else{
     				backUrl();
     				close_window();
     				//goUrl("__URL__/index/week/{$Think.get.week}");
     			}
     		}else{
     			//close_window();
     			$.messager.show({title:'提示信息',msg:result.info,timeout:2000,showType:'slide'});
     		}
     	}
 	});
}

function edit(id){
	$('#id').val(id);
	$.post('__URL__/editAjax/id/'+id, function(data, textStatus, xhr) {
		//alert(unix2date('Y-m-d',data.riqi))
		$('#riqi').datebox('setValue', unix2date('Y-m-d',data.riqi));	
		$("input[type=radio][value="+data.sxw+"]").attr("checked",'checked');
		$('#title').val(data.title);
		$('#address').val(data.address);
		$('#Participants').val(data.Participants);
		$('#editor').val(data.remarks);
		editor.html(data.remarks);
	},'json');
	$('#w1').window('open');
}

</script> 
